/**
 * 保存数据
 */
export function save(key: string, value: any) {
  localStorage.setItem(key, JSON.stringify(value))
  return true
}

/**
 * 删除指定key的数据
 */
export function take<T = any>(key: string): T | undefined {
  const value = localStorage.getItem(key)
  if (value == null) return undefined
  return JSON.parse(value) as T;
}

/**
 * 清空所有数据
 */
export function clear() {
  localStorage.clear()
}
